<?php
 class Novel
 {
     protected static $cover_ignore = array( '767d51c0c288a119a0021617e07aec17', '885c458c8f2047f10fbe347dffde48fe', '4e8e0d052be5d59f05e86cc667ea0cf3', '8c8dc7f74a2aa2efe6440a96af1d0fba', '69112d56eb663ffbbb6e06749b76c05e', '7f7362f276d7acda4eadc18f71981025', '3651be6e1b146dbd5810de07aff78f32', '39d605f5f65af52b451a9ca4106c9584', 'd4185bff0ada6042009a1876d3f96a4e', '73e8b26cc6daf8167f8edfecb8ad9fbc', '7f45805421b479df86d389e893f1b9ff', '8a6a4dc2fea4c5deddf6814970a04ed5', '7de5137232efaab5c324acd6ce40fe3a', '85df644ca2709d9b3b8ce0bf1c1347bb', '1940de03c4ee83d5ca064a1d0c6bbb5f', 'bb2e8e60484b10cb68484cd6f75781f3', '4f71b11aa36a2756ed4624c1b3a26f3b', '88f75e0c2b987b92952ae734d6409c61', '200fea58b89dfebfe00de3cafaa7f3a5', '6f6e87de9f61cdc75d836afdb7595c7f', '31938f8130e14c528b8f838d2f267ef1', '9981a8f73ad447b9138d4615a518fa64', '585eb6d76f86abb786516d58fc238be3', '622dd0813269c9ea51f1456b208d53c0', 'b6a6eb372ffa06450a11cd3e5fe73c01', '0c94ea41ece4dc4bcc997b25d4404750', );
     public static function checkCover($zym_15)
     {
         if (empty($zym_15)) {
             return '';
         }
         $zym_14 = explode('.', basename(strtolower($zym_15)));
         $zym_14 = $zym_14['0'];
         if (stripos("noimg|nocover|default", $zym_14) !== false) {
             return '';
         }
         $zym_13 = http::get($zym_15);
         if (empty($zym_13) or strlen($zym_13) < 100) {
             return '';
         }
         if (stristr($zym_13, '访问的内容不存在') or stristr($zym_13, '<hr><center>nginx') or stristr($zym_13, '<title>Error</title>') or stristr($zym_13, '404 Not Found')) {
             return '';
         }
         if (stristr($zym_13, '<html') and stristr($zym_13, '<head') and stristr($zym_13, '<title') and stristr($zym_13, '<?php') != false) {
             return '';
         }
         $zym_17 = md5($zym_13);
         if (in_array($zym_17, self::$cover_ignore)) {
             return '';
         }
         if (C('collect_cover_save')) {
             $zym_18 = "/public/cover/{$zym_17[0]}{$zym_17[1]}/{$zym_17[2]}{$zym_17[3]}/{$zym_17[4]}{$zym_17[5]}/$zym_17.jpg";
             if (!is_file(PT_ROOT.$zym_18)) {
                 if (!is_dir(dirname(PT_ROOT . $zym_18))) {
                     mkdir(dirname(PT_ROOT . $zym_18), 0755, true);
                 }
                 if ($zym_13{0} !='<' && $zym_12 = imagecreatefromstring($zym_13)) {
                     imagejpeg($zym_12, PT_ROOT . $zym_18);
                     $zym_15=$zym_18;
                 } else {
                     $zym_15='';
                 }
             } else {
                 $zym_15=$zym_18;
             }
         }
         return $zym_15;
     }
     public static function getcategory($zym_16)
     {
         static $rule;
         if (!$rule) {
             $zym_10 = explode("\n", C('collect_category_rule'));
             foreach ($zym_10 as $zym_19) {
                 $rule[strstr($zym_19, '|', true)] = substr(strstr($zym_19, '='), 1);
             }
         }
         foreach ($rule as $zym_6 => $zym_19) {
             if (preg_match('{' . $zym_19 . '}', $zym_16)) {
                 return $zym_6;
             }
         }
         return C('collect_category_default');
     }
     public static function chapterformat($zym_20, $zym_16 = '', $zym_18 = '')
     {
         $zym_20=urldecode($zym_20);
         if ($zym_18) {
             $zym_20 = str_ireplace(explode('.', parse_url($zym_18, PHP_URL_HOST)), '', $zym_20);
         }
         if ($zym_16) {
             $zym_20 = preg_replace('/(更新)?\s*' . str_replace(' ', '\s*', preg_quote($zym_16, '/')) . '\s*/', '', $zym_20);
         }
         $zym_20 = str_ireplace(array('www.', '.com', '.cn', '.cc', '.org', '.me', '.net', 'http', '://'), '', $zym_20);
         $zym_20 = str_ireplace(array('<br/>', '<br />', '<br>'), "\n", $zym_20);
         $zym_20 = preg_replace('/<\/p>\s*<p>/i', "\n", $zym_20);
         $zym_20 = trim(str_ireplace(array('<p>', '</p>', "\r"), array("\n", "\n", "\n"), $zym_20));
         $zym_20 = str_replace("\r", "\n", $zym_20);
         $zym_20 = preg_replace("{\s+　　\s+}", "\n", $zym_20);
         $zym_20 = preg_replace("/\n{2,}/", "\n", $zym_20);
         $zym_20 = trim(str_replace(array('　', '&nbsp;'), ' ', $zym_20));
         $zym_5 = explode("\n", $zym_20);
         foreach ($zym_5 as $zym_6 => $zym_7) {
             $zym_7=trim($zym_7);
             $zym_7=preg_replace('/^(　|，|、|。|；|：|？|！)+/', '', $zym_7);
             $zym_7=preg_replace('/(　)+$/', '', $zym_7);
             $zym_7=trim($zym_7);
             if (!$zym_7) {
                 unset($zym_5[$zym_6]);
             }
             $zym_5[$zym_6] = $zym_7;
         }
         $zym_20 = implode("\n", $zym_5);
         $zym_20 = strip_tags($zym_20, '<img>');
         $zym_20 = (trim($zym_20));
         return $zym_20;
     }
     public static function introformat($zym_21)
     {
         $zym_11 = array("。", "！", "？", "!", "?", '.', '…');
         $zym_21 = PT_Base::getInstance()->filter->safetext($zym_21);
         $zym_21 = trim(str_replace(array('　', ' ', '&nbsp;'), '', $zym_21));
         $zym_21 = str_ireplace(array('<br/>', '<br />', '<br>'), "\n", $zym_21);
         $zym_21 = str_replace(array("\r", '\n', '\r'), "\n", $zym_21);
         $zym_21 = preg_replace("/\n{2,}/", "\n", $zym_21);
         $zym_21 = str_replace('读网络文学就用盛大Bambook，多款优惠套装官网促销中！', '', $zym_21);
         $zym_5 = explode("\n", $zym_21);
         $zym_8 = 0;
         foreach ($zym_5 as $zym_6 => $zym_7) {
             $zym_7 = trim($zym_7);
             if ($zym_8 > 0 && (in_array($zym_7, $zym_11) || in_array($zym_7, array('”', '"', "'", "）", "（")))) {
                 $zym_5[$zym_8] .= $zym_7;
                 unset($zym_5[$zym_6]);
                 continue;
             };
             if (!$zym_7) {
                 unset($zym_5[$zym_6]);
                 continue;
             }
             if (in_array($zym_7{0}, array(',', '?', ':', ';', '；', '：'))) {
                 $zym_7 = preg_replace('/^[,?:;；：]/', '', $zym_7);
             }
             $zym_5[$zym_6] = $zym_7;
             $zym_8 = $zym_6;
         }
         return implode("\n", $zym_5);
     }
     public static function nameformat($zym_16)
     {
         $zym_16 = str_replace(array('　', '&nbsp;'), ' ', urldecode($zym_16));
         $zym_16 = preg_replace('/\.+$/', '', $zym_16);
         $zym_16 = preg_replace('/…+$/', '', $zym_16);
         $zym_9 = array( array('<', '>'), array('[', ']'), array('(', ')'), array('{', '}'), array('〈', '〉'), array('《', '》'), array('（', '）'), array('「', '」'), array('『', '』'), array('［', '］'), array('〖', '〗'), array('【', '】'), array('｛', '｝'), );
         foreach ($zym_9 as $zym_19) {
             if (strpos($zym_16, $zym_19['0']) !== false && strpos($zym_16, $zym_19['1']) === false) {
                 $zym_16 = str_replace($zym_19['0'], ' ', $zym_16);
             }
         }
         $zym_16 = preg_replace('/(\s|　)+/', ' ', $zym_16);
         $zym_16 = preg_replace('/^[\d\s]+?第/', '第', $zym_16);
         return $zym_16;
     }
     public static function clearNovelName($zym_16)
     {
         $zym_16=trim(strip_tags($zym_16));
         $zym_16=str_replace(['_塔读文学网','_甜悦读','_南京阅明','_逐浪小说','_杭州趣阅','_凤凰网','_博易创为','_飞卢','_品书网','_蔷薇书院','_幻文小说网','_黑岩','_岳麓','_红杉万橡','_二层楼','_酷匠网','_酷匠网','_杭州悦蓝','_一千零一页','_书海','_华夏天空','_凤鸣轩','_瑞隆文化','_中润','_铁血科技','_永正'], '', $zym_16);
         $zym_16=str_replace(['(塔读文学网)','(塔读文学网1)','(甜悦读)','(南京阅明)','(逐浪小说','(杭州趣阅)','(凤凰网)','(博易创为)','(飞卢)','(品书网)','(蔷薇书院)','(幻文小说网)','(黑岩)','(岳麓)','(红杉万橡)','(二层楼)','(酷匠网)','(酷匠网)','(杭州悦蓝)','(一千零一页)','(书海)','(华夏天空)','(凤鸣轩)','(瑞隆文化)','(中润)','(铁血科技)','(永正'], '', $zym_16);
         $zym_16=str_replace('(书坊)', '', $zym_16);
         return $zym_16;
     }
     public static function clearAuthorName($zym_16)
     {
         $zym_16=trim(strip_tags($zym_16));
         $zym_16=str_replace(['_塔读文学网','_甜悦读','_南京阅明','_逐浪小说','_杭州趣阅','_凤凰网','_博易创为','_飞卢','_品书网','_蔷薇书院','_幻文小说网','_黑岩','_岳麓','_红杉万橡','_二层楼','_酷匠网','_酷匠网','_杭州悦蓝','_一千零一页','_书海','_华夏天空','_凤鸣轩','_瑞隆文化','_中润','_铁血科技','_永正'], '', $zym_16);
         $zym_16=str_replace('(书坊)', '', $zym_16);
         return $zym_16;
     }
 }
